#!/usr/bin/perl
#creat_rsync.cgi

require './remotesync-lib.pl';
&ReadParse();
@minute=(0..59,);
@hour=("*",0..23);
@day=("*",1..31);
@month=("*",1..12);
@week=("*",0..6);
@bindwidth=("Unlimit","2MB/s","4MB/s","8MB/s","16MB/s");
&header($text{'mirror_title'}, "" , "index", 0, 1,);
#print $in{'sharedir'};
#print $in{'command'};
print "<form name='crform' action=modify.cgi methiod=post onsubmit='on_form_submit()'>\n";
print "<table class=mode1 width=80%>\n";
print "<tr><td width=150>$text{'mirror_ip'}</td><td><input type=text name=ip class=text></td></tr>\n";
$mod="volume2";
print "<tr><td width=150>$text{'mirror_modname'}</td><td><input type=text name=mod class=text></td></tr>\n";
$path = "/usrvol/volume1/";
print "<tr><td width=150>$text{'mirror_path'}</td><td><input type=text name=localpath class=text></td></tr>\n";

print "<tr><td width=150>$text{'mirror_type'}</td><td><input type=checkbox name=optupd checked>$text{'mirror_update'}</td></tr>\n";
print "<tr><td width=150></td><td><input type=checkbox name=optdel checked>$text{'mirror_delete'}</td></tr>\n";

print "<tr><td width=150>$text{'bindwidth'}</td><td>";
print "<select name=bw>";
foreach(@bindwidth){
	if($_ =~ /Unlimit/){
    		print "<option value='$_'>$text{'unlimit'}</option>\n";
	}
	else{
		print "<option value='$_'>$_</option>\n";
	}
}
print "</select></td></tr>\n";


print "<tr><td width=150>$text{'mirror_rule'}</td><td>$text{'mirror_minute'}&nbsp;\n";

print "<select name=minute size=1>\n";
foreach(@minute){
    print "<option value='$_'>$_</option>\n";
}
print "</select>";
print "</td></tr>\n";

print "<tr><td width=150></td><td>$text{'mirror_hour'}&nbsp;&nbsp;\n";
print "<select name=hour size=1>\n";
foreach(@hour){
    print "<option value='$_'>$_</option>\n";
}
print "</select>";
print "</td></tr>\n";

print "<tr><td width=150></td><td>$text{'mirror_day'}&nbsp;&nbsp;\n";
print "<select name=day size=1>\n";
foreach(@day){
    print "<option value='$_'>$_</option>\n";
}
print "</select>";
print "</td></tr>\n";

print "<tr><td width=150></td><td>$text{'mirror_month'}\n";
print "<select name=month size=1>\n";
foreach(@month){
    print "<option value='$_'>$_</option>\n";
}
print "</select>";
print "</td></tr>\n";





print "</table>\n";

print "<table border=0 class=mode1><tr><td>\n";
print "<input type=submit name=modify value=$text{'mirror_create'} class=button1 onclick='return on_create_click(\"$text{'mirror_no_ipmodpath'}\");'>\n";
print "<input type=submit name=cancle value=$text{'mirror_cancle'} class=button1 onclick='return on_cancle_click()'>\n";
print "</td></tr></table>\n";
print "<input type=hidden name=cropt1>";
print "<input type=hidden name=cropt2>";

print "<input type=hidden name=crt_path value=\"$path\">";
print "<input type=hidden name=crt_mod value=\"$mod\">";
print "<input type=hidden name=modtype value=create>";
print "</form>\n";

print <<EOF;
<script>
function on_form_submit()
{





    if(document.crform.optupd.checked)
    {
         document.crform.cropt1.value = '-vau';  
    }
    else
    {
         document.crform.cropt1.value = '-va';  
    }

    if(document.crform.optdel.checked)
    {
         document.crform.cropt2.value = '--delete --ignore-errors';
    }
    else
    {
        document.crform.cropt2.value = '';
    }
}
function on_create_click(mesg_no_ip)
{
//    alert("create!");
    if(document.crform.ip.value == "" || document.crform.mod.value == "" || document.crform.localpath.value == "")
    {
        alert(mesg_no_ip);
        return false; 
    }
//    if(document.crform.mod.value == "")
//    {
//        alert(msg_no_mod);
//        return false;
//    }
//    if(document.crform.localpath.value == "")
//    {
//        alert("msg_no_path");
//        return false;
//    }
//    alert("create end");
}
function on_cancle_click()
{
    document.crform.action = "cancle.cgi";
}
</script>
EOF

&footer("index.cgi", $text{'index'});
